<script setup>
import * as echarts from 'echarts'
import { onMounted } from 'vue'
import { ref } from 'vue'

const line = ref()

onMounted(() => {
  let myCharts = echarts.init(line.value)
  myCharts.setOption({
    // x|y轴
    xAxis: {
      type: 'category',
      // 两侧不留白
      boundaryGap: false,
      // 分割线不要
      splitLine: {
        show: false
      },
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
      // 轴线的设置
      axisLine: {
        show: true
      },
      // 刻度
      axisTick: {
        show: true
      },
      axisLabel: {
        color: 'white'
      }
    },
    yAxis: {
      // 分割线不要
      splitLine: {
        show: false
      },
      // 轴线的设置
      axisLine: {
        show: true
      },
      // 刻度
      axisTick: {
        show: true
      },
      axisLabel: {
        color: 'white'
      }
    },
    grid: {
      left: 30,
      top: 20,
      bottom: 55,
      right: 70
    },
    // 系列
    series: {
      type: 'line',
      data: [100,300,400,500,3452,412,300],
      // 平滑曲线设置
      smooth: true,
      // 设置填充样式
      areaStyle: {
        color: {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0, color: 'red'
            },
            {
              offset: 1, color: 'blue'
            }
          ]
        }
      }
    }
  })
})
</script>

<template>
  <div class="box5">
    <div class="title">
      <p>未来30天游客量趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="">
    </div>
    <div class="charts" ref="line">

    </div>
  </div>
</template>

<style scoped lang="less">
.box5 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  // background-size: 100% 100%;
  margin: 20px 20px 0 20px;
  .title {
    p {
      color: white;
      font-size: 16px;
      margin-bottom: 8px;
    }
  }
  .charts {
    height: calc(100% - 40px);
  }
}
</style>
